package cn.itcast.service.impl;

import cn.itcast.dao.cargo.FinanceDao;

import cn.itcast.domain.cargo.Finance;
import cn.itcast.domain.cargo.FinanceExample;

import cn.itcast.dao.cargo.InvoiceDao;
import cn.itcast.domain.cargo.Finance;
import cn.itcast.domain.cargo.FinanceExample;
import cn.itcast.domain.cargo.Invoice;
import cn.itcast.service.FinanceService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class FinanceServiceImpl implements FinanceService {
    @Autowired
    private FinanceDao financeDao;
    @Autowired
    private InvoiceDao invoiceDao;

    @Override
    public PageInfo findAll(FinanceExample financeExample, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Finance> list = financeDao.selectByExample(financeExample);
        System.out.println(list);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public void delete(String id) {
        financeDao.deleteByPrimaryKey(id);
    }

    @Override
    public Finance findById(String id) {
        Finance finance = financeDao.selectByPrimaryKey(id);
        return finance;
    }

    @Override
    public void edit(Finance finance) {
        financeDao.insertSelective(finance);

    }


}